<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/2/1 0001
  Time: 下午 6:57
  To change this template use File | Settings | File Templates.
  管理员管理
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>${sessionScope.title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../admin/css/x-admin.css" media="all">
    <link rel="stylesheet" href="/layui-v2.2.5/layui/css/layui.css" media="all">
    <style>
     body{
         height:100%;
     }
     .x-body{
         /*height:1400px;*/
         min-height:1600px;
     }
    </style>
</head>
<body>

<div class="x-nav">
    <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>营销管理</cite></a>
              <a><cite>奖品领取</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="/adminSystem/prizeGet" style="width:80%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name"  placeholder="请输入会员名" value="${name}" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <input type="text" id="tel" name="tel"  placeholder="请输入电话" value="${tel}" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </div>
    </form>
    <p style="width: 50px;height:30px;float:right;margin-top:-3%;margin-right:3%;"><button class="layui-btn" onclick="myToExcel();">导出数据</button></p>

    <%--<xblock>
      <button class="layui-btn" onclick="role_add('添加活动','/adminSystem/addActivity?agentId=${returnData.agentId}','1500','700')"><i class="layui-icon">&#xe608;</i>添加活动</button>
    </xblock>
    --%>
   <%-- <div id="fenye" style="text-align: center" ></div>--%>
    <table class="layui-table">
        <thead>
        <tr>
            <th>序号</th>
            <th>会员名</th>
            <th>会员电话</th>
            <th>购买时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${returnData}" var="da" varStatus="s">
            <tr>
                <td>${s.index+1}</td>
                <td>${da.name}</td>
                <td>${da.tel}</td>
                <td><fmt:formatDate value="${da.createTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                <td>${da.state}</td>
                    <td class="td-manage">
                        <c:if test="${da.state!='已领取'}">
                            <button class="layui-btn" onclick="update('${da.id}')">领取奖品</button>
                        </c:if>
                    </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div id="page"></div>
    <div id="fenye" style="text-align: center" ></div>
</div>
<script src="/js/layui/layui.all.js" charset="utf-8"></script>
<script src="/admin/js/x-layui.js" charset="utf-8"></script>
<script src="/admin/js/jquery.min.js" charset="utf-8"></script>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
<script type="application/javascript">
    /*分页*/
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;
        //自定义排版
        laypage.render({
            elem: 'fenye'
            ,count: parseInt(${totalRows})
            ,limit:${limit}
            ,layout: ['limit', 'prev', 'page', 'next','count'/*,'skip'*/]
            ,curr: ${currentPage}
            ,hash: 'fenye' //自定义hash值
            ,jump: function(obj,first){
                var curr=obj.curr;//当前页
                var limit=obj.limit;//每页显示的条数
                //首次不执行
                if(!first){
                    //写自己的逻辑
                    window.location.href="/adminSystem/prizeGet?currentPage="
                        +curr+"&size="+limit;
                }else {

                }
            }
        });

    });

</script>
<script>
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(sreach)', function(data){
        });
    });
    function update(id){
        $.ajax({
            type:"POST",
            url:"/adminSystem/updateState?id="+id,
            success:function (date) {
                if(date){
                    self.location="/adminSystem/prizeGet";
                }
            }
        })
    }


    function  myToExcel() {
        window.location.href="/activity1990/prizeToExcel";
    }

</script>
</body>
</html>
